package com.walter.myweb.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.walter.myweb.mapper.ContentsDao;
import com.walter.myweb.pojo.Contents;
import com.walter.myweb.service.ContentService;

@Service
public class ContentServiceImpl implements ContentService {

	@Autowired
	private ContentsDao contentDao;
	
	@Override
	public List<Contents> selectContents() {
		// TODO Auto-generated method stub
		return contentDao.selectContents();
	}

	@Override
	public void addContentByTagId(Contents content) {
		Date date=new Date();
		content.setCreate_time(date);
		content.setDelete_time(null);
		content.setStatus(1);
		contentDao.addContent(content);
	}

	@Override
	public List<Contents> selectContents(String condition) {
		
		return contentDao.selectContentsByCondition(condition);
	}

	@Override
	public void updateContentById(Contents content) {
		Date date=new Date();
		//如果status为1，则deleteTime为最后修改时间
		content.setDelete_time(date);
		contentDao.updateContentById(content);
	}

	@Override
	public void deleteContentByID(Contents content) {
		Date date=new Date();
		//如果status为1，则deleteTime为最后修改时间
		content.setDelete_time(date);
		contentDao.deleteContentByID(content);;
		
	}


}
